package org.example.day20240813;

import java.util.Arrays;
import java.util.Scanner;

public class test6 {
    public static void main(String[] args) {
//        6
//        10 2 6 3 7 8
        Scanner scanner = new Scanner(System.in);
        String num = scanner.nextLine();
        String line = scanner.nextLine();
        String[] strArr = line.split(" ");
        int[] arr = new int[strArr.length];
        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(strArr[i]);
        }
        Arrays.sort(arr);
        int count = 0;
        for(int i = 0;i<arr.length;i++){
            if((i+1) != arr.length && (arr[i+1]-arr[i])==1){
                count++;
            }
        }
        System.out.println(count);
    }
}
